package com.wzx.user.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.wzx.common.pojo.resp.Result;
import com.wzx.user.mapper.SystemMsgMapper;
import com.wzx.user.mapper.SystemNoticeMapper;
import com.wzx.user.pojo.SystemNotice;
import com.wzx.user.service.SystemNoticeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

/**
 * @author wzx
 * @version 1.0
 * @date 2023/6/6 - 14:13
 * @description 标题
 */
@Service
public class SystemNoticeServiceImpl extends ServiceImpl<SystemNoticeMapper, SystemNotice> implements SystemNoticeService {

    @Autowired
    private SystemNoticeMapper systemNoticeMapper;

    @Override
    public Result getSystemNoticeByPage(long pageNum, long pageSize) {

        Page<SystemNotice> page = new Page<>();
        page.setCurrent(pageNum);
        page.setSize(pageSize);

        QueryWrapper<SystemNotice> queryWrapper = new QueryWrapper<>();
        queryWrapper.orderByDesc("createTime");

        IPage<SystemNotice> systemNoticeIPage = systemNoticeMapper.selectPage(page, queryWrapper);

        return Result.successByPage(systemNoticeIPage.getCurrent(),
                systemNoticeIPage.getSize(), systemNoticeIPage.getTotal(), systemNoticeIPage.getPages(), systemNoticeIPage.getRecords());


    }
}
